<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template="../template/index.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core">
	<ui:define name="title">	
		<title>Department</title>
		<h:outputScript library="js" name="jquery.cookie.js"  />
		<h:outputScript library="js" name="jquery.treeview.js"  />
		<h:outputStylesheet library="css" name="jquery.treeview.css" />
		<script>
		$(document).ready(function(){
			// third example
			$("#department").treeview({
				animated: "normal",
				collapsed: false,
				control: "#treecontrol"
			});
		});
		function select(id){
			var id_dep = id + "";
			$("#formDep\\:dep_id").val(id_dep);
			document.forms["formDep"].submit();
		}
		</script>
	</ui:define>
	<ui:define name="lcontent">
		<ui:include src="../template/menu-left/human-resources.xhtml"></ui:include>
	</ui:define>
	<ui:define name="rcontent">
		<f:event type="postAddToView" listener="#{departmentManagement.onload}" />
		<h:form id="formDep">
			<f:event type="preRenderView" listener="#{companyInfoBean.onload}" />
			<div class="control">
				<div class="control-button">
					<h:commandLink onclick="loading();" action="#{departmentManagement.update}" rendered="#{departmentManagement.action == 'select'}">
						<img src="#{facesContext.externalContext.requestContextPath}/resources/images/icon/edit.png" />
						<span>#{msg['edit']}</span>									
					</h:commandLink>
					<h:commandLink onclick="loading();" action="#{departmentManagement.delete}" rendered="#{departmentManagement.action == 'select'}">
						<img src="#{facesContext.externalContext.requestContextPath}/resources/images/icon/trash.png" />
						<span>#{msg['delete']}</span>									
					</h:commandLink>
					<h:commandLink onclick="loading();" action="#{departmentManagement.insert}" rendered="#{departmentManagement.action == 'new'}">
						<img src="#{facesContext.externalContext.requestContextPath}/resources/images/icon/plus.png" />
						<span>Thêm</span>
					</h:commandLink>
				</div>
				<span class="clear"></span>
			</div>
			<div class="loading">
				<img src="#{facesContext.externalContext.requestContextPath}/resources/images/loading.gif" />
			</div>
			<div class="rcontent-main">
				<div class="input-lpanel">
					<div style="padding: 5px">
						<h:inputHidden id="dep_id" value="#{departmentManagement.id_dep}"></h:inputHidden>
						<h:outputText value="#{departmentManagement.str_tree}" escape="false"/>
						#{departmentManagement.str_tree}
					</div>
				</div>
				<div class="input-rpanel">
					<span class="input-table-caption">Thông tin bộ phận</span>
					<table class="input-table w100">
						<tr>
							<td class="input-table-first">Mã phòng ban</td>
							<td><h:inputText id="id" styleClass="input" value="#{departmentManagement.department.id}" maxlength="50"/>
							</td>
						</tr>
						<tr>
							<td class="input-table-first">Tên bộ phận</td>
							<td><h:inputText id="name" styleClass="input" value="#{departmentManagement.department.kywd}" maxlength="50"/>
							</td>
						</tr>
						<tr>
							<td class="input-table-first">Mô tả</td>
							<td>
								<h:inputTextarea id="birthday" styleClass="input" value="#{departmentManagement.department.dscptn}"/>
							</td>
						</tr>
						<tr>
							<td class="input-table-first">Phòng cấp trên</td>
							<td>
								<h:selectOneMenu id="sex" styleClass="input w50" value="#{departmentManagement.department.partid}">
									<f:selectItems value="#{departmentManagement.listDep}" var="dep" itemLabel="#{dep.kywd}" itemValue="#{dep.id}"/>
								</h:selectOneMenu>
							</td>
						</tr>
					</table>
				</div>
			</div>
		</h:form>
	</ui:define>
</ui:composition>